package com.xuetang9.fujian.net;

import com.xuetang9.fujian.mychat.entity.BizType;
import com.xuetang9.fujian.mychat.util.SysDTO;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author: fujian
 * @description:
 * @date: 2021/5/10 16:44
 * @version: V1.0
 * @package: com.xuetang9.fujian.net
 **/
public class Client {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Socket socket = new Socket("localhost",8888);
        ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
        ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());

        while (true){
            SysDTO dto = new SysDTO(BizType.登录);
            dto.setNickName("测试登录用户名");
            dto.setPassword("测试登录密码");
            outputStream.writeObject(dto);
            outputStream.flush();

            // 接收服务端的消息
             dto = (SysDTO) inputStream.readObject();
            System.out.println("接收到来自服务端的消息："+dto.getBizType());
            System.out.println("输入任意字符继续：");
            new Scanner(System.in).next();
        }
    }
}
